package com.ecoolex.ying.space.ws;

import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.common.pojo.Sorting;
import com.ecoolex.ying.space.core.manager.PickGoodsChannelManager;
import com.ecoolex.ying.space.core.manager.PickGoodsLabelAssociateManager;
import com.ecoolex.ying.space.core.manager.PickGoodsManager;
import com.ecoolex.ying.space.core.manager.PickGoodsProductManager;
import com.ecoolex.ying.space.core.service.PickGoodsSearchService;
import com.ecoolex.ying.space.entity.PickGoods;
import com.ecoolex.ying.space.entity.PickGoodsChannel;
import com.ecoolex.ying.space.entity.PickGoodsProduct;
import com.ecoolex.ying.space.entity.PickGoodsWithBLOBs;
import com.ecoolex.ying.space.pojo.EditPickGoodsDTO;
import com.ecoolex.ying.space.pojo.EditPickGoodsProductDTO;
import com.ecoolex.ying.space.pojo.QueryPickGoodsDTO;
import com.ecoolex.ying.space.pojo.SearchPickGoodsDTO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class PickGoodsServiceImpl implements PickGoodsService {

    @Autowired
    private PickGoodsManager pickGoodsManager;
    @Autowired
    private PickGoodsProductManager pickGoodsProductManager;
    @Autowired
    private PickGoodsChannelManager pickGoodsChannelManager;
    @Autowired
    private PickGoodsLabelAssociateManager pickGoodsLabelAssociateManager;
    @Autowired
    private PickGoodsSearchService pickGoodsSearchService;

    @Override
    public PickGoodsWithBLOBs createPickGoods(Integer goodsId, EditPickGoodsDTO add, String createUser) {
        return pickGoodsManager.create(goodsId, add, createUser);
    }

    @Override
    public void updatePickGoods(Integer pickGoodsId, EditPickGoodsDTO edit, String updateUser) {
        pickGoodsManager.update(pickGoodsId, edit, updateUser);
    }

    @Override
    public void deletePickGoods(PickGoodsWithBLOBs record, String updateUser) {
        pickGoodsManager.delete(record, updateUser);
    }

    @Override
    public void onlinePickGoods(PickGoodsWithBLOBs record, String updateUser) {
        pickGoodsManager.online(record, updateUser);
    }

    @Override
    public void offlinePickGoods(PickGoodsWithBLOBs record, String updateUser) {
        pickGoodsManager.offline(record, updateUser);
    }

    @Override
    public long countPickGoodsByClassifyId(Integer classifyId) {
        return pickGoodsManager.countByClassifyId(classifyId);
    }

    @Override
    public long countPickGoodsByGoodsId(Integer goodsId) {
        return pickGoodsManager.countByGoodsId(goodsId);
    }

    @Override
    public long countPickGoodsByLabelId(Integer labelId) {
        return pickGoodsLabelAssociateManager.countByLabelId(labelId);
    }

    @Override
    public PickGoodsWithBLOBs getPickGoodsById(Integer pickGoodsId) {
        return pickGoodsManager.getById(pickGoodsId);
    }


    @Override
    public Pagination<PickGoodsWithBLOBs> searchPickGoods(SearchPickGoodsDTO query, Page page) {
        return pickGoodsSearchService.search(query, page);
    }

    @Override
    public Pagination<PickGoodsWithBLOBs> queryPickGoods(QueryPickGoodsDTO query, Sorting[] sorts, Page page) {
        return pickGoodsManager.query(query, sorts, page);
    }

    @Override
    public Pagination<PickGoodsWithBLOBs> queryPickGoodsByUserFavorite(Integer userId, String keyword, Page page) {
        return pickGoodsManager.queryByUserFavorite(userId, keyword, page);
    }

    @Override
    public PickGoodsProduct createProduct(PickGoods goods, Integer productId, EditPickGoodsProductDTO add, String createUser) {
        return pickGoodsProductManager.create(goods, productId, add, createUser);
    }

    @Override
    public void updateProduct(Integer pickProductId, EditPickGoodsProductDTO edit, String updateUser) {
        pickGoodsProductManager.update(pickProductId, edit, updateUser);
    }

    @Override
    public void deleteProduct(PickGoodsProduct record, String updateUser) {
        pickGoodsProductManager.delete(record, updateUser);
    }

    @Override
    public PickGoodsProduct getProductById(Integer pickProductId) {
        return pickGoodsProductManager.getById(pickProductId);
    }

    @Override
    public List<PickGoodsProduct> queryProductByPickGoodsId(Integer pickGoodsId) {
        return pickGoodsProductManager.queryByPickGoodsId(pickGoodsId);
    }

    @Override
    public PickGoodsChannel createChannel(PickGoodsChannel record, String createUser) {
        return pickGoodsChannelManager.create(record, createUser);
    }

    @Override
    public void updateChannel(PickGoodsChannel record, String updateUser) {
        pickGoodsChannelManager.update(record, updateUser);
    }

    @Override
    public void deleteChannel(PickGoodsChannel record, String updateUser) {
        pickGoodsChannelManager.delete(record, updateUser);
    }

    @Override
    public PickGoodsChannel getChannelById(Integer channelId) {
        return pickGoodsChannelManager.getById(channelId);
    }

    @Override
    public List<PickGoodsChannel> queryChannelByPickGoodsId(Integer pickGoodsId) {
        return pickGoodsChannelManager.queryByPickGoodsId(pickGoodsId);
    }
}
